package com.lanou.moving.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lanou.moving.R;

/**
 * Created by dllo on 15/11/4.
 */
public class GuideFragment extends Fragment {
    private static final String KEY_CONTENT = "TestFragment:Position";
    protected static final int[] CONTENT = new int[]{

            R.mipmap.nutural,
            R.mipmap.nuturally,
            R.mipmap.hello,
            R.mipmap.mai_1




    };
    private int mPosition;

    public static GuideFragment newInstance(int position) {
        GuideFragment fragment = new GuideFragment();
        fragment.mPosition = position;
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if ((savedInstanceState != null)
                && savedInstanceState.containsKey(KEY_CONTENT)) {
            mPosition = savedInstanceState.getInt(KEY_CONTENT);
        }
        View root = inflater
                .inflate(R.layout.guide_fragment, container, false);
        root.setBackgroundResource(CONTENT[mPosition]);
        return root;
    }

    @Override
    //保存当前的状态
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt(KEY_CONTENT, mPosition);
    }
}
